package com.docker.login;

import com.docker.core.interceptor.InterceptorToken;
import com.docker.core.interceptor.InterceptorUnToken;
import com.docker.core.mvc.Remark;
import com.docker.core.mvc.controller.BaseAPIController;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;

/**
 * @Author ldl
 * @Create 2020/10/09 009 16:51
 */
@Remark("登录管理")
@Before(LoginValidator.class)
public class LoginController extends BaseAPIController {

    @Inject
    private LoginService loginService;

    @Remark("获取登录短信验证码")
    @Before(InterceptorUnToken.class)
    public void sms() {
        renderAPI(loginService.sms(getPara("app_id"), getPara("account")));
    }

    @Remark("DUM平台登录")
    @Before(InterceptorUnToken.class)
    public void index() {
        renderAPISuccess(loginService.login(getPara("app_id"), getPara("account"), getPara("app_version"), getPara("sms_code"), getRequestIP()));
    }

    @Remark("获取用户信息")
    @Before(InterceptorToken.class)
    public void info() {
        renderAPISuccess(loginService.info(getPara("app_id"), getPara("token")));
    }

    @Remark("获取菜单权限")
    @Before(InterceptorToken.class)
    public void auth() {
        renderAPISuccess(loginService.auth(getPara("app_id"), getPara("token")));
    }

    @Remark("退出登录")
    @Before(InterceptorToken.class)
    public void logout() {
        //退出应用中的全部token
        renderAPI(loginService.logout(getPara("app_id"), getPara("token")));
    }

}
